'use strict';

const path = require('path');
const async = Promise.resolve();

module.exports = {
  async,
  constants: {
    error: {
      ArgumentsNotFound: new Error('Arguments Not Found'),
    },
  },
  resolve(...paths) {
    return path.resolve(__dirname, '../../', ...paths);
  },
  /**
   *
   * @param {Promise} promise
   * @return {{success:boolean,data?:unknown,message?:string}}
   */
  async result(promise = async) {
    return await promise.then(
      data => {
        const res = { success: true };
        if (data !== undefined) res.data = data;
        return res;
      },
      err => {
        return {
          success: false,
          message: err.toString(),
        };
      }
    );
  },
};
